<div class="layui-fluid" id="VIEW-list-table" lay-title="数据检测">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">筛选数据</div>
                <div class="layui-card-body">
                    <form class="layui-form" lay-filter="lig-check-searchform">
                        <input type="hidden" name="bizType" value="1">
                        <input type="hidden" name="checkType" value="1">
                        <div class="layui-inline">
                            <label class="layui-form-label">检测状态</label>
                            <div class="layui-input-inline">
                                <select name="checkFlag">
                                    <option value="0">未检测</option>
                                    <option value="1">已检测</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">手机号码</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="telNumber" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">客户名称</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="customerName" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <input type="button" class="layui-btn layui-btn-sm" lay-filter="lig-check-search" lig-lang="btn-search" value="查询">
                            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary" lig-lang="btn-reset">重置</button>
                        </div>
                    </form>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <div class="layui-tab layui-tab-brief" lay-filter="lig-ckeck-type-tab">
                        <ul class="layui-tab-title" id="check_type">
                            <li class="layui-this" data-check-type="1">空号检测</li>
                            <li data-check-type="3">二要素检测</li>
                        </ul>
                    </div>
                    <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm" lay-filter="lig-check-excute">检测</div>
                    </div>
                    <table lay-filter="lig-check-table"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="tpl-row-toolBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs lig-modify" lay-event="lig-modify" title="修改">修改</a>
</script>

<script>
    layui.use(['admin', 'table', 'form', 'dropdown', 'element', 'jquery','lig'], function (admin, table, form, dropdown, element, $, lig) {
        var getSelected = function() {
            var _datas = table.checkStatus('checkId').data,  _ids = ''
                , _length = _datas.length;
            if (_length > 0) {
                $.each(_datas, function (i, item) {
                    _ids += "," + item["id"];
                });
                if (_ids != '') {
                    _ids = _ids.substring(1);
                }
            }
            return _ids;
        };


        form.render();

        var checkTable = lig.table({
            elem: '[lay-filter="lig-check-table"]',
            url: 'bu/check/queryMobileCheck',
            cols: [[
                { title: '', type: 'checkbox', fixed: true, width: 60 },
                { title: '手机号码', field: 'telNumber', width: '20%' },
                { title: '公司名称', field: 'customerName', width: '30%' },
                { title: '法人', field: 'legal', width: '20%' },
                { title: '检测结果', field: 'checkResult', width: '25%' }

            ]]
        },{
            mode:'dialog',
            entity: 'check',
            primaryField: 'id'
        });

        element.on('tab(lig-ckeck-type-tab)', function(data){
            $('[lay-filter="lig-check-searchform"] input[name="checkType"]').val($(this).attr('data-check-type'));
            checkTable.reloadTable();
        });

        $('[lay-filter="lig-check-excute"]').click(function() {
            var ids = getSelected();
            if (ids == '') {
                lig.alert('请选择数据');
                return;
            }

            lig.load();
            var checkType = $('[lay-filter="lig-check-searchform"] input[name="checkType"]').val();
            lig.ajaxget({
                url: 'bu/check/executeMobileCheck',
                data: {
                    checkType: checkType,
                    ids: ids
                },
                success: function(res) {
                    lig.unload();
                    if (res.data) {
                        var msg = '';
                        if (checkType == 1) {
                            msg = '完成空号检测，共' + res.data.total + '条，空号' + res.data.dealTotal + '条';
                        } else if (checkType == 3) {
                            msg = '完成二要素检测，共' + res.data.total + '条，一致' + res.data.dealTotal + '条';
                        }
                        checkTable.reloadTable();
                        lig.alert(msg);
                    }
                }
            });
        });

    })
</script>